package cn.javass.dp.iterator.example5;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class PayManager extends Aggregate {

    private List list = new ArrayList();


    public void calcPay() {
        PayModel pm1 = new PayModel();
        pm1.setPay(1000);
        pm1.setUserName("张三");
        PayModel pm2 = new PayModel();
        pm2.setPay(2000);
        pm2.setUserName("李四");
        list.add(pm1);
        list.add(pm2);
    }

    @Override
    public Iterator createIterator() {
        return list.iterator();
    }

    public Object get(int index) {
        Object obj = null;
        if (index <= list.size()-1) {
            obj = this.list.get(index);
        }
        return obj;
    }

    public int size() {
        return this.list.size();
    }
}
